from tortoise.models import Model
from tortoise import fields


# models User
class User(Model):
    id = fields.IntField(pk=True)
    username = fields.CharField(max_length=50, unique=True)
    email = fields.CharField(max_length=100, unique=True)
    created_at = fields.DatetimeField(auto_now_add=True)
    updated_at = fields.DatetimeField(auto_now=True)

    class Meta:
        table = "users"

    def __str__(self):
        return f"User({self.username}, {self.email})"

    class PydanticMeta:
        exclude = ("created_at", "updated_at")
